# -*-Dockerfile-*-
FROM debian:stretch
RUN apt update && \
    apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev pkg-config wget git
RUN wget https://github.com/ldc-developers/ldc/releases/download/v1.17.0/ldc2-1.17.0-linux-armhf.tar.xz && \
    tar -xvf ldc2-1.17.0-linux-armhf.tar.xz
COPY . /usr/src/onedrive
RUN cd /usr/src/onedrive/ && \
    ./configure DC=/ldc2-1.17.0-linux-armhf/bin/ldmd2 && \
    make clean && \
    make && \
    make install

FROM debian:stretch-slim
ENTRYPOINT ["/entrypoint.sh"]
RUN apt update && \
    apt install -y gosu libcurl3 libsqlite3-0 && \
    rm -rf /var/*/apt && \
    mkdir -p /onedrive/conf /onedrive/data
COPY contrib/docker/entrypoint.sh /
COPY --from=0 /usr/local/bin/onedrive /usr/local/bin/
